package com.xgpro.pc.archives.controller;


import com.xgpro.common.results.ResponseResult;
import com.xgpro.domain.archives.dto.ApprovalInfo;
import com.xgpro.domain.archives.entity.Patent;
import com.xgpro.domain.archives.entity.Project;
import com.xgpro.domain.archives.entity.SixSigma;
import com.xgpro.pc.archives.service.PcArchivesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@CrossOrigin(allowCredentials="true")
@RequestMapping("/archives/pc")
public class PcArchivesController {

    @Autowired
    private PcArchivesService pcArchivesService;

    @GetMapping(value = "/getApproval")
    public ResponseResult getApproval(String rankName,String deptName,Integer status,Integer pageNum,Integer pageSize){
        return pcArchivesService.getApproval(rankName,deptName,status,pageNum,pageSize);
    }

    @GetMapping(value = "/getApprovalInfo")
    public ResponseResult getApprovalInfo(Integer id){
        return pcArchivesService.getApprovalInfo(id);
    }


    @PostMapping(value = "/updateApproval")
    public ResponseResult updateApproval(@RequestBody ApprovalInfo approvalInfo){
        return pcArchivesService.updateApproval(approvalInfo);
    }

    @DeleteMapping(value = "/deleteApproval")
    public ResponseResult deleteApproval(@RequestParam("ids") List<Integer> ids){
        return pcArchivesService.deleteApproval(ids);
    }


    @GetMapping(value = "/getRankName")
    public ResponseResult getRankName(){
        return pcArchivesService.getRankName();
    }

    @GetMapping(value = "/getDeptName")
    public ResponseResult getDeptName(){
        return pcArchivesService.getDeptName();
    }

    @GetMapping(value = "/ui")
    public ResponseResult getArchives(String name,String deptName,Integer eduKind,Integer pageNum,Integer pageSize){
        return pcArchivesService.getArchives(name,deptName,eduKind,pageNum,pageSize);
    }

    @GetMapping(value = "/getUser")
    public ResponseResult getUser(Integer userId){
        return pcArchivesService.getUser(userId);
    }


    @GetMapping(value = "/getPanent")
    public ResponseResult getPanentInfo(Integer userId,String name,Integer type, Integer pageNum, Integer pageSize){
        return pcArchivesService.getPanent(userId,name,type,pageNum,pageSize);
    }

    @GetMapping(value = "/getProject")
    public ResponseResult getProject(Integer userId,String name,Integer type,Integer pageNum,Integer pageSize){
        return pcArchivesService.getProject(userId,name,type,pageNum,pageSize);
    }

    @DeleteMapping(value = "/deleteUser")
    public ResponseResult deleteUser(@RequestParam("ids") List<Integer> ids){
        return pcArchivesService.deleteUser(ids);
    }

    @DeleteMapping(value = "/deletePatent")
    public ResponseResult deletePatent(@RequestParam("ids") List<Integer> ids){
        return pcArchivesService.deletePatent(ids);
    }

    @DeleteMapping(value = "/deleteProject")
    public ResponseResult  deleteProject(@RequestParam("ids") List<Integer> ids){
        return pcArchivesService.deleteProject(ids);
    }
    @PostMapping(value = "/addPatent")
    public ResponseResult addPatent(@RequestBody Patent patent){
        return pcArchivesService.addPatent(patent);
    }

    @PostMapping(value = "/addProject")
    public ResponseResult addProject(@RequestBody Project project){
        return pcArchivesService.addProject(project);
    }

    @PutMapping(value = "/updateProject")
    public ResponseResult updateProject(@RequestBody Project project){
        return pcArchivesService. updateProject(project);
    }

    @PutMapping(value = "/updatePatent")
    public ResponseResult updatePatent(@RequestBody Patent patent){
        return pcArchivesService.updatePatent(patent);
    }

    @GetMapping(value = "/getSix")
    public ResponseResult getSix(Integer userId){
        return pcArchivesService.getSix(userId);
    }

    @PutMapping(value = "/updateSix")
    public ResponseResult updateSix(@RequestBody SixSigma sigma){
        return pcArchivesService. updateSix(sigma);
    }

}